package day04;
import java.util.Scanner;
//猜数字游戏
public class Guessing {
    public static void main(String[] args) {
//        int num=250;
        Scanner scanner=new Scanner(System.in);
        int num=(int)(Math.random()*1000+1);
        System.out.println(num);//作弊
//        System.out.println(Math.random());
        /*
        Math.random        0.00000-0.99999999
        *1000               0.00000-999.999999

         */
        /*
        300 猜大了 200 猜小了 250 猜对了
         */
        int gusses;
        do {
            System.out.println("猜吧");

            gusses=scanner.nextInt();//1+3循环变量的初始化和循环变量的改变是同一个
            if (gusses>num){
                System.out.println("猜大了");

            }else if (gusses<num){
                System.out.println("猜小了");
            }else{
                System.out.println("猜对了");
            }

        }while(gusses!=num);//循环条件

















      /*  System.out.println("猜吧");

       int  guess=scanner.nextInt();//1
       while(guess!=num){//2
           //用if....else 还是用if......else if
           //提示：
           if (guess>num){
               System.out.println("猜大了");
           }else{
               System.out.println("猜小了");
           }
           System.out.println("猜吧");
           guess=scanner.nextInt();//3
       }
        System.out.println("恭喜你，猜对了");

       */
/*
                                  guess=300
          300!=250 300>250true 猜大了 200
          200！=250 200》250false 猜小了 250
          250=250 false while结束 猜对了
 */


    }

}
